#include "../logs/log.h"
#include <unistd.h>
void test_log(const std::string &name)
{
    INFO("%s","测试开始");
    bitlog::Logger::ptr logger = bitlog::LoggerManager::getInstance().getLogger(name);
    logger->debug("%s","测试日志"); 
    logger->info("%s","测试日志"); 
    logger->warn("%s","测试日志"); 
    logger->error("%s","测试日志"); 
    logger->fatal("%s","测试日志"); 
    // DEBUG("%s","测试日志"); 
    // INFO("%s","测试日志"); 
    // WARN("%s","测试日志"); 
    // ERROR("%s","测试日志"); 
    // FATAL("%s","测试日志"); 
    // size_t count = 0;
    // std::string str = "测试日志-";
    // while (count < 500000)
    // {
    //     FATAL("测试日志-%d",count++); 
    // }
    INFO("%s","测试结束");
    
}
int main()
{

    std::unique_ptr<bitlog::LoggerBuilder> builder(new bitlog::GlobalLoggerBuilder());
    builder->buildLoggerLevel(bitlog::LogLevel::value::DEBUG);
    builder->buildLoggerName("async_logger");
    builder->buildFormatter("[%c][%f:%l][%p]%m%n");
    builder->buildLoggerType(bitlog::LoggerType::LOGGER_SYNC);
    builder->buildSink<bitlog::FileSink>("./logfile/sync.log");
    builder->buildSink<bitlog::StdoutSink>();
    builder->buildSink<bitlog::RollBySizeSink>("./logfile/roll-sync-by-size.log",1024 * 1024);
    builder->build();
    test_log("async_logger");


    return 0;
}